All of the following examples use
This takes the substring from the beginning of the string to the specified index.
If you don’t understand String.Index, see my previous answer.
This takes the substring from the specified index to the end of the string.
This one just gives you a substring based on the Range you pass in. Once you have the range, it’s easy. Although still not as convenient as the old NSRange, this is a definite improvement over Swift 2 ranges.
Reference: how does string substring work in swift 3